package com.ehualu.check;

import com.ehualu.check.utils.CheckUtil;
import com.ehualu.check.utils.MysqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Author: 吴敬超
 * @Date: 2021/3/17 17:18
 */
public class CheckFile {

    private static final Logger LOG = LoggerFactory.getLogger(CheckFile.class);

    public void check() {
        MysqlUtil mysqlUtil = new MysqlUtil();
        List<Map<String, String>> checkInfoList = mysqlUtil.getCheckinfo();

        CheckUtil checkUtil = new CheckUtil();
        for (int i = 0; i < checkInfoList.size(); i++) {

            try {
                LOG.info("校验文件：" + checkInfoList.get(i).get("ext_path"));

//                checkUtil.checkfile(checkInfoList.get(i).get("id"), checkInfoList.get(i).get("ext_path"), checkInfoList.get(i).get("ext_hash_mothod"));
                checkUtil.checkfile(checkInfoList.get(i).get("id"), checkInfoList.get(i).get("ext_path"));

            } catch (IOException e) {
                e.printStackTrace();
                LOG.info("计算校验出错，校验文件的ID：" + checkInfoList.get(i).get("id"));

            }
        }
    }


    public static void main(String[] args) {

        CheckFile checkFile = new CheckFile();
        checkFile.check();

    }

}
